<!-- HTML header for doxygen 1.8.8-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <!-- For Mobile Devices -->
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
        <meta name="generator" content="Doxygen 1.8.11"/>
        <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
        <title>DJI Onboard SDK: osdk-core/advanced-sensing-2.0.0/inc/linux_usb_device.hpp Source File</title>
        <!--<link href="tabs.css" rel="stylesheet" type="text/css"/>-->
        <script type="text/javascript" src="dynsections.js"></script>
        <link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
        <link href="doxygen.css" rel="stylesheet" type="text/css" />
        <link href="customdoxygen.css" rel="stylesheet" type="text/css"/>
        <link href='https://fonts.googleapis.com/css?family=Roboto+Slab' rel='stylesheet' type='text/css'>
        <link rel="shortcut icon" href="favicon.png" type="image/x-icon" />
        <link rel="stylesheet" href="bootstrap.min.css">
        <script src="bootstrap.min.js"></script>
        <script type="text/javascript" src="doxy-boot.js"></script>
    </head>
    <body>
        <nav id="site-header" class="site-header navbar">
            <div class="container">
                <div class="navbar-header"><a href="" class="logo"><img src="dji-logo@2x.png">Developer</a></div>
                <div id="header-navbar" class="collapse navbar-collapse">
                    <ul class="nav navbar-nav">
                        <li class="hovedown"><a href="javascript:void(0);" class="hovedown-toggle">SDK<span class="caret"></span></a>
                            <ul class="hovedown-menu">
                                <li><a href="/mobile-sdk">Mobile SDK</a></li>
                                <li><a href="/onboard-sdk">Onboard SDK</a></li>

                            </ul>
                        </li>
                        <li><a href="/products">Products</a></li>
                        <li><a href="/showcase">Showcase</a></li>
                        <li><a href="/news">News</a></li>
                        <li><a href="http://forum.dev.dji.com/en" target="_blank">Forum</a></li>
                        <li class="hovedown"><a href="javascript:void(0);" class="hovedown-toggle">GitHub<span class="caret"></span></a>
                            <ul class="hovedown-menu">
                                <li><a href="https://github.com/dji-sdk/Mobile-SDK-iOS" target="_blank">iOS SDK</a></li>
                                <li><a href="https://github.com/dji-sdk/Mobile-SDK-Android" target="_blank">Android SDK</a></li>
                                <li><a href="https://github.com/dji-sdk/Onboard-SDK" target="_blank">Onboard SDK</a></li>

                            </ul>
                        </li>
                        <li><a href="/challenge2016" target="_blank">Challenge</a></li>
                    </ul>
                </div>
            </div>
        </nav>
        <div data-offset-top="60" data-spy="affix" class="sub-nav">
            <div class="container">
                <h1 class="logo">Onboard SDK</h1>
                <nav><a href="/onboard-sdk">Overview</a><a href="/onboard-sdk/documentation">Documentation</a><a href="/onboard-api-reference/index.html" class="active">API Reference</a><a href="/onboard-sdk/downloads">Downloads</a>
                </nav>
            </div>
        </div>
        <!--<nav class="navbar navbar-default" role="navigation">-->
            <!--<div class="container">-->
                <!--<div class="navbar-header">-->
                    <!--<a href="#" class="navbar-left"><img src="dji_logo_gray_small.png" alt="DJI OSDK API Documentation" width="32px"/></a>-->
                    <!--<a class="navbar-brand" href="index.html">ONBOARD SDK 3.3</a>-->
                <!--</div>-->
            <!--</div>-->
        <!--</nav>-->
        <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
            <div class="content" id="content">
                <div class="container">
                    <div class="row">
                        <div class="col-sm-12 panel " style="padding-bottom: 15px; padding-top: 52px;">
                            <div style="margin-bottom: 15px;">
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_95d02babf7f2c2cbb8138434e234b0a4.html">osdk-core</a></li><li class="navelem"><a class="el" href="dir_f2583c6e7b7612631c3fdbaaac734bac.html">advanced-sensing-2.0.0</a></li><li class="navelem"><a class="el" href="dir_a3f83bc09053d57469bb64017c364da9.html">inc</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">linux_usb_device.hpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="linux__usb__device_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;</div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="preprocessor">#ifndef ONBOARDSDK_LINUX_USB_DEVICE_H</span></div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="preprocessor">#define ONBOARDSDK_LINUX_USB_DEVICE_H</span></div><div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;</div><div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="preprocessor">#include &lt;cstring&gt;</span></div><div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="preprocessor">#include &lt;fcntl.h&gt;</span></div><div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="preprocessor">#include &lt;termios.h&gt;</span></div><div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="preprocessor">#include &lt;unistd.h&gt;</span></div><div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="preprocessor">#include &lt;libusb.h&gt;</span></div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;</div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="preprocessor">#include &quot;dji_hard_driver.hpp&quot;</span></div><div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;</div><div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;</div><div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespaceDJI.html">DJI</a></div><div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;{</div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;</div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;<span class="keyword">namespace </span>OSDK</div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;{</div><div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;</div><div class="line"><a name="l00033"></a><span class="lineno"><a class="line" href="classDJI_1_1OSDK_1_1LinuxUSBDevice.html">   33</a></span>&#160;<span class="keyword">class </span><a class="code" href="classDJI_1_1OSDK_1_1LinuxUSBDevice.html">LinuxUSBDevice</a> : <span class="keyword">public</span> HardDriver</div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;{</div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;  <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> POSSIBLE_DJI_DEVICE_NUM  = 6;</div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;  <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> TIMEOUT                  = 50;</div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;  <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> OUT_END_PT               = 0x0A;</div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;  <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">int</span> IN_END_PT                = 0x84;</div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;</div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;  <span class="keyword">typedef</span> <span class="keyword">struct </span>USBFilter</div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;  {</div><div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;    uint16_t  vid;</div><div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;    uint16_t  pid;</div><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;  } USBFilter;</div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;</div><div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;</div><div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;<span class="comment">//  static const int BUFFER_SIZE = 2048;</span></div><div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;</div><div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;<span class="comment">//  LinuxUSBDevice(const char* device, uint32_t baudrate);</span></div><div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;  <a class="code" href="classDJI_1_1OSDK_1_1LinuxUSBDevice.html">LinuxUSBDevice</a>();</div><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;  ~<a class="code" href="classDJI_1_1OSDK_1_1LinuxUSBDevice.html">LinuxUSBDevice</a>();</div><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;</div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;  <span class="keywordtype">void</span> init();</div><div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;  <span class="keywordtype">bool</span> isDJIUSBDevice(uint16_t idVendor, uint16_t idProduct);</div><div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;</div><div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;  <span class="keywordtype">size_t</span> <a class="code" href="classDJI_1_1OSDK_1_1LinuxUSBDevice.html#ac78bd1bd1f32ada883b3a4be6105a31d">send</a>(<span class="keyword">const</span> uint8_t* buf, <span class="keywordtype">size_t</span> len);</div><div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;  <span class="keywordtype">size_t</span> readall(uint8_t* buf, <span class="keywordtype">size_t</span> maxlen);</div><div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;</div><div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;  time_ms getTimeStamp();</div><div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;<span class="keyword">private</span>:</div><div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;  libusb_device*        DJI_device;</div><div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;  libusb_device_handle* DJI_dev_handle;</div><div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;  <span class="keywordtype">int</span>                   DJI_device_product_id;</div><div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;  USBFilter             DJI_usb_dev_filter[POSSIBLE_DJI_DEVICE_NUM];</div><div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;</div><div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;  <span class="keywordtype">bool</span>                  deviceStatus;</div><div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;  <span class="keywordtype">bool</span>                  foundDJIDevice;</div><div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;};</div><div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;}</div><div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;}</div><div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;</div><div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;</div><div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;<span class="preprocessor">#endif //ONBOARDSDK_LINUX_USB_DEVICE_H</span></div><div class="ttc" id="classDJI_1_1OSDK_1_1LinuxUSBDevice_html_ac78bd1bd1f32ada883b3a4be6105a31d"><div class="ttname"><a href="classDJI_1_1OSDK_1_1LinuxUSBDevice.html#ac78bd1bd1f32ada883b3a4be6105a31d">DJI::OSDK::LinuxUSBDevice::send</a></div><div class="ttdeci">size_t send(const uint8_t *buf, size_t len)</div><div class="ttdoc">Start of DJI_HardDriver virtual function implementations. </div></div>
<div class="ttc" id="namespaceDJI_html"><div class="ttname"><a href="namespaceDJI.html">DJI</a></div><div class="ttdef"><b>Definition:</b> dji_ack.cpp:38</div></div>
<div class="ttc" id="classDJI_1_1OSDK_1_1LinuxUSBDevice_html"><div class="ttname"><a href="classDJI_1_1OSDK_1_1LinuxUSBDevice.html">DJI::OSDK::LinuxUSBDevice</a></div><div class="ttdoc">POSIX-Compatible USB Driver for *NIX platforms. </div><div class="ttdef"><b>Definition:</b> linux_usb_device.hpp:33</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- HTML footer for doxygen 1.8.8-->
<!-- start footer part -->
</div>
</div>
</div>
</div>
</div>
<hr class="footer"/><address class="footer"><small>
  <footer id="site-footer" class="site-footer">
    <div class="container">
      <div class="foot-nav row">
        <nav class="link-list col-xs-2"><span class="title">SDK</span><a href="/mobile-sdk">Mobile SDK</a><a href="/ux-sdk">UX SDK</a><a href="/onboard-sdk">Onboard SDK</a><a href="/payload-sdk">Payload SDK</a><a href="/windows-sdk">Windows SDK</a></nav>
        <nav class="link-list col-xs-2"><span class="title">Info</span><a href="/products">Products</a></nav>
        <nav class="link-list col-xs-2"><span class="title">Community</span><a href="http://stackoverflow.com/questions/tagged/dji-sdk" target="_blank">Stack Overflow</a><a href="https://www.youtube.com/channel/UCPQwN5xsob8zZGIcDhkYqUA" target="_blank">YouTube</a><a href="https://twitter.com/djidevelopers" target="_blank">Twitter</a></nav>
        <nav class="link-list col-xs-2"><span class="title">Contact Us</span><a href="mailto:dev@dji.com"> dev@dji.com</a></nav>
        <nav class="link-list col-xs-2"><span class="title">Business Cooperation</span><a href="mailto:dev@dji.com"> dev@dji.com</a></nav>
        <nav class="link-list col-xs-2"><span class="title">BILLING</span><a href="mailto:billing-dev@dji.com"> billing-dev@dji.com</a></nav>
      </div>
      <div class="foot-copyright row">
        <div class="col-xs-3 foot-logo"><img src="dji-logo-foot.png"></div>
        <div class="copyright col-xs-7"><span>Copyright © 2018 DJI All Rights Reserved</span><a href="/policies/privacy">Privacy Policy</a><a href="/policies/terms">Terms of Use</a></div>
        <div class="col-xs-2">
          <div class="lang-selector">
            <select dir="rtl" v-model="lang">
              <option value="en">English</option>
              <option value="cn">中文</option>
            </select>
          </div>
        </div>
      </div>
    </div>
  </footer>
</small></address>
</body>
</html>
